package com.hand.rch25287.zuoye003.service;

import com.hand.rch25287.zuoye003.mapper.LineMapper;
import com.hand.rch25287.zuoye003.condition.OrderLineQueryCondition;
import com.hand.rch25287.zuoye003.result.OrderLineQueryResult;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 25287
 * @create 2019 - 07 17 11:35
 */
public class LineService {
    private static ApplicationContext ctx;
    private static LineMapper lineMapper;
    static {
        ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        lineMapper = (LineMapper) ctx.getBean(LineMapper.class);
    }

    public List<OrderLineQueryResult> selectOrderLinesByCondition(OrderLineQueryCondition condition){
        List<OrderLineQueryResult> orderLineQueryResults = new ArrayList<>();
        try {
            orderLineQueryResults = lineMapper.selectOrderLinesByCondition(condition);
        }catch (Exception e){
            e.printStackTrace();
        }
        return orderLineQueryResults;
    }
}
